﻿/* Copyright 2010 Igor Francé
 * 
 * This file is part of ECMADoc (http://ecmadoc.codeplex.com).
 * 
 * ECMADoc is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * ECMADoc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with ECMADoc. 
 * If not, see http://www.gnu.org/licenses/.
 */
namespace EcmaDoc.Core
{
	using System;
	using System.Text.RegularExpressions;

	using Items;

	/// <summary>
	/// Provides a parse context with all information required for match handlers.
	/// </summary>
	public struct ParseContext
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="ParseContext"/> structure, using the specified
		/// <paramref name="parser"/>, parse <paramref name="mode"/> and <paramref name="context"/> code item.
		/// </summary>
		/// <param name="parser">The current parser.</param>
		/// <param name="mode">The current parse mode.</param>
		/// <param name="context">The current code item in which a parser is operating.</param>
		public ParseContext(Parser parser, ParseMode mode, CodeItem context)
			: this()
		{
			this.Parser = parser;
			this.Mode = mode;
			this.Object = context;
			this.Match = null;
		}

		/// <summary>
		/// Gets or sets the regular expression that was used to find this match.
		/// </summary>
		public Regex Regex { get; set; }

		/// <summary>
		/// Gets or sets the regular expression match that was found.
		/// </summary>
		public Match Match { get; set; }

		/// <summary>
		/// Gets the parse mode in which the match occured.
		/// </summary>
		public ParseMode Mode { get; private set; }

		/// <summary>
		/// Gets the current parser.
		/// </summary>
		public Parser Parser { get; private set; }

		/// <summary>
		/// Gets the current code item in which a parser is operating
		/// </summary>
		public CodeItem Object { get; private set; }
	}
}
